//谁看了我的简历
import React, {Component} from 'react';
import {
    View,
    Text,
    Image,
    TouchableOpacity,
} from 'react-native';

import {followStyle as styles} from '../../../../styles';
import fmt from '../../../util/fmtDateUtil';
import Nature from '../../../util/Nature';
import {common_url} from "../../../util/fetch";

var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;
var height = Dimensions.get('window').height;

export default class ChakanLv extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <TouchableOpacity
                style={styles.fol_allin}
                onPress={() => {
                    this.goGet('Company', this.props.company.companyId)
                }}
                activeOpacity={1}>
                <View style={styles.fol_topa}>
                    <Image source={
                        this.props.company.companyPicture ?
                            {uri: common_url + "uploadImg/" + this.props.company.companyPicture}
                            : require('../../../img/app/company.png')} style={styles.fol_head}/>
                    <View style={[styles.fol_tr, {width: width * 0.7}]}>
                        <View style={styles.fol_in1}>
                            <Text style={styles.fol_bpos}>{this.props.company.companyName}</Text>

                        </View>
                        <View style={styles.fol_in2}>
                            <Text style={styles.fol_pla}>{this.props.company.companyCity}</Text>
                            {this.fieldName(this.props.domains, 2)}
                        </View>
                        <View style={styles.fol_in5}>
                            <Text style={styles.fol_com}>{Nature(this.props.company.companyNature)}</Text>
                        </View>
                    </View>
                </View>

                <View style={[styles.fol_botb, {width: width * 0.9}]}>
                    <View style={styles.fol_in6}>
                        <Text style={styles.fol_hot}>热门职位 :</Text>
                    </View>

                    <View style={styles.fol_in7}>
                        {this.postionName(this.props.postions, 2)}
                    </View>

                    <View style={styles.fol_in8}>
                        <Text style={styles.fol_time}>{fmt(this.props.resume.browseTime, "yyyy-MM-dd")}</Text>
                    </View>

                </View>
            </TouchableOpacity>
        )
    }

    fieldName(List, sl) {
        let data = {
            cont: List
        }
        let arr = [];
        let s = sl;
        let length = data.cont.length
        if (length <= s) {
            s = length
        }
        for (let i = 0; i < s; i++) {
            arr.push(
                <Text key={i} style={styles.fol_pla}>{data.cont[i].field.fieldName}</Text>
            )
        }
        return arr;
    }

    postionName(List, sl) {
        let arr = [];
        if(List!=undefined){
        let s = sl;
        let length = List.length
        if (length <= s) {
            s = length
        }
        for (let i = 0; i < s; i++) {
            arr.push(
                <Text key={i} style={styles.fol_hotin}>{List[i].postionName}</Text>
            )
        }
    }
        return arr;
    }

    goGet(name, id) {
        this.props.navigation.navigate(name, {useId: id});
    }
}